<template>
	<view>
		<view class="bg1580E7 " :style="{paddingTop:shh+'px'}"></view>
		<view class="pt20 pb30 bg1580E7 ">
			
			
			<view v-if="token"  class="con flex-a-i">
				<image :src="user.avatar" class="wh140-140 ra140"></image>
				<view class=" ml20">
					<view class="colorfff size30">{{user.nickname}}</view>
					<view class="flex-ju-b  color737373 mt10">
						<view v-if="user.is_vip==1" class="bg3A3F56 pg2-15 colorFFDAB7 ra10 size25">VIP会员</view>
						<view v-else class="bgBFBFBF pg2-15 ra10 size25">体验用户</view>
					</view>
				</view>
			</view>
			
			<button v-else @click="login" class="butt">
				<view  class="con flex-a-i">
					<image src="/static/denglui.png" class="wh140-140 ra140"></image>
					
					<view class=" ml20">
						<view class="colorfff size30">点击登录</view>
					</view>
					
				</view>
			</button> 
			
		</view>
		<view class="posire">
			<view @click="dengl" v-if="!token" class=" posiab zindex50 width100vw height100vh"></view>
			
		<view v-if="user.is_vip" @click="navto('activate_vip')" class="con posire">
			<image class="image mt20" mode="widthFix" src="/static/vip.png"></image>
			<view class="flex-a-i posiab top30 left30">
				<image class="image height30" mode="heightFix" src="/static/vvip.png"></image>
				<view class="size41 color712205 bold">{{user.vip_level_name}}</view>
			</view>
			<view class="flex-a-i posiab top90 size30 left30">
				{{user.vip_overdue_time}}到期
			</view>
			<view class="bg383C55 colorFFDEA5 size30 posiab right0 pl20 top50  wh165-70 flex-ju-c border-r">
			    查看权益
			</view>
		</view>
		<view v-else @click="navto('activate_vip')" class="con posire">
			<image class="image mt20" mode="widthFix" src="/static/vip.png"></image>
			<view class="flex-a-i posiab top30 left30">
				<image class="image height30" mode="heightFix" src="/static/vvip.png"></image>
				<view class="size41 color712205 bold">会员</view>
			</view>
			<!-- <view class="flex-a-i posiab top90 size30 left30">
				免费体验VIP，每天低至1.1
			</view> -->
			<view class="bg383C55 colorFFDEA5 size30 posiab right0 pl20 top50 wh165-70 flex-ju-c border-r">
				立刻开通
			</view>
		</view>
		
		<view class="border-tD3D3D3 mt20"></view>
		<view @click="navto('enterprise_info')" class="bgfff pt30">
			<view class="flex-ju-b con">
				<view>企业信息</view>
				<uni-icons type="right" size="20" color="#231815"></uni-icons>
			</view>
			<view class="border-tD3D3D3 mt30"></view>
		</view>
		<view @click="navto('record')" class="bgfff pt30">
			<view class="flex-ju-b con">
				<view>年报预审记录</view>
				<uni-icons type="right" size="20" color="#231815"></uni-icons>
			</view>
			<view class="border-tD3D3D3 mt30"></view>
		</view>
		<view @click="navto('customer_service')" class="bgfff pt30">
			<view class="flex-ju-b con">
				<view>联系客服</view>
				<uni-icons type="right" size="20" color="#231815"></uni-icons>
			</view>
			<view class="border-tD3D3D3 mt30"></view>
		</view>
	</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				user:{},
				code:"",
				hasUserInfo: false,
				canIUseGetUserProfile: false,
				token:''
			}
		},
		onLoad() {
			this.token=uni.getStorageSync('token')
			if(this.token){
				this.http('userinfo').then(res=>{
					this.user=res.data
					uni.setStorageSync('user',res.data)
				}).catch(res=>{
					this.token=''
				})
			}
			
		},
		methods: {
			dengl(){
				uni.showToast({
					title:'请先登录',
					icon:"none"
				})
			},
			selcetAvatar(e){
				console.log(e)
			},
			 getUserInfo(e) {
				 console.log(e)
			 }, 
			login(){
				
				uni.login({
				  provider: 'weixin',
				  success:(loginRes) =>{
					  this.code=loginRes.code
					this.http('v2/routine/login',{
						code:this.code
					}).then(res=>{
						
						uni.setStorageSync("token",res.data.token)
						this.token=res.data.token
						// this.user = res.data.userInfo
						
						this.http('userinfo').then(res=>{
							uni.showToast({
								title:'登录成功',
								icon:"none"
							})
							this.user=res.data
							uni.setStorageSync('user',res.data)
						}).catch(res=>{
							this.token=''
						})
						
					})
				  }
				});
				
				
					// this.http('login',{
					// 	 account:"wx61281733819660",//wx831130
					// 	password:"test123",
					// },'post').then(res=>{
					// 	console.log(res.data)
					// 	uni.setStorageSync("token",res.data.token)
					// 		this.token=res.data.token
					// })
				
			}
		}
	}
</script>

<style>
	.butt{
		background: none;
		border: none;
	}
	uni-button:after{
		border: none;
	}
	button:after{
		border: none;
	}
.border-r{
	border-top-left-radius: 30px;
	border-bottom-left-radius: 30px;
}
</style>
